from abc import ABC, abstractmethod
from .timestamp_change import convert_timestamp

class DeleteStrategy(ABC):
    @abstractmethod
    def delete_content(self, task_id):
        pass

    @abstractmethod
    def delete_comments(self, task_id):
        pass


class BaseDataQueryStrategy(ABC):
    """基础数据查询策略类"""
    
    # 定义需要转换的时间戳字段
    timestamp_fields = ['time', 'last_update_time', 'add_ts']
    
    def process_timestamp_fields(self, data_list: list) -> list:
        """处理数据中的时间戳字段"""
        processed_data = []
        for item in data_list:
            processed_item = item.copy()
            for field in self.timestamp_fields:
                if field in item and item[field]:
                    processed_item[field] = convert_timestamp(item[field])
            processed_data.append(processed_item)
        return processed_data

    @abstractmethod
    def get_platform_data(self, task_id: str, **kwargs):
        """获取平台数据的抽象方法"""
        pass

    @classmethod
    def get_strategy(cls, platform_name: str):
        """获取对应平台的策略类"""
        pass